package com.cqw.auth.config.handler;

import com.cqw.auth.enums.CodeEnum;
import com.cqw.auth.utils.ResultJSON;
import com.cqw.auth.utils.SecurityHandlerUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 账号或者密码错误
 * @Author cqw
 * @Date 2020年12月31日15:08:34
 */
public class LoginFailureHandlerImpl implements AuthenticationFailureHandler {
    @Override
    public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        SecurityHandlerUtil.responseHandler(httpServletResponse,new ResultJSON(CodeEnum.USER_NOT_EXIST_FAILURE));
    }
}
